# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

import unittest
import sys

from Mathutils import Euler
from Mathutils import Vector
from Mathutils import Matrix
from b2xp_utils import B2XP_Vertex

class TestB2xpUtilsVertex(unittest.TestCase):

    def setUp(self):
        pass

    def test_construct_from_vector(self):
        vector = Vector(0.0, 1.0, 2.0)
        matrix = Matrix([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
        vertex = B2XP_Vertex.from_vector(vector, matrix)
        self.assertEqual(vertex.x, 0.0)
        self.assertEqual(vertex.y, 2.0)
        self.assertEqual(vertex.z, -1.0)

        try:
            vertex = B2XP_Vertex.from_vector(0, matrix) # Invaild input data
        except:
            self.assertRaises(TypeError)

        euler = Euler(0.0, 1.0, 2.0)
        matrix = Matrix([1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1])
        vertex = B2XP_Vertex.from_euler(euler, matrix)
        self.assertEqual(vertex.x, 0.0)
        self.assertEqual(vertex.y, 2.0)
        self.assertEqual(vertex.z, -1.0)

        try:
            vertex = B2XP_Vertex.from_euler(euler, 0.0) # Invaild input data
        except:
            self.assertRaises(TypeError)



if __name__ == "__main__":

    suite = unittest.TestLoader().loadTestsFromTestCase(TestB2xpUtilsVertex)
    #suite.addTest(unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase))
    unittest.TextTestRunner(verbosity=2).run(suite)